package com.css.fxfzdpzs.modules.home.controller;

import com.alibaba.fastjson.JSONObject;
import com.css.fxfzdpzs.base.response.RestResponse;
import com.css.fxfzdpzs.modules.home.service.HomeService;
import com.css.fxfzdpzs.modules.home.vo.HomeVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author y1fan
 * @description
 */
@RestController
@RequestMapping("/dpzs")
@Slf4j
public class HomeController {


    @Resource
    private HomeService homeService;

    /**
     * 首页
     *
     * @return
     */
    @GetMapping("/home")
    public RestResponse getHome() {
        RestResponse restResponse = null;
        JSONObject jsonObject = new JSONObject();
        try {
            HomeVO homeVO=homeService.getHome();
            jsonObject.put("message", "查询成功!");
            restResponse = RestResponse.succeed(homeVO);
        } catch (Exception e) {
            String errormessage = "查询失败";
            log.error(errormessage, e);
            restResponse = RestResponse.fail(errormessage);
        }
        return restResponse;
    }
}
